package br.edu.sistemaacademico;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.text.Document;

import br.edu.sistemaacademico.Decorator.ConcretDecorator;
import br.edu.sistemaacademico.adapter.IMenuCadastro;
import br.edu.sistemaacademico.builder.ClasseDAO;
import br.edu.sistemaacademico.facade.DataFacade;
import br.edu.sistemaacademico.observer.Observavel;
import br.edu.sistemaacademico.observer.Observer;
import br.edu.sistemaacademico.observer.ValidaEspecial;
import br.edu.sistemaacademico.pojo.Classe;
import br.edu.sistemaacademico.pojo.Curso;
import br.edu.sistemaacademico.pojo.Disciplina;
import br.edu.sistemaacademico.pojo.Professor;
import br.edu.sistemaacademico.pojo.Turma;
import client.ClientCommand;

/**
 *
 * @author baron
 */
public class frmAtualizaTurma extends IMenuCadastro {

    ConcretDecorator cc = null;
    ClasseDAO classeDao = new ClasseDAO();
    Turma turma;
    Curso curso;
    Classe classe;
    Professor professor;
    Disciplina disciplina;
    public frmAtualizaTurma(Turma turma) {
       this.turma = turma;
       execute();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable3 = new javax.swing.JTable();

        setPreferredSize(new java.awt.Dimension(430, 194));

        jLabel1.setText("N Vagas");
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText("Periodo");
        jLabel2.setName("jLabel2"); // NOI18N

        jTextField2.setName("jTextField2"); // NOI18N
        jTextField2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField2ActionPerformed(evt);
            }
        });

        jTextField3.setName("jTextField3"); // NOI18N
        jTextField3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField3ActionPerformed(evt);
            }
        });

        jButton5.setText("Cancelar");
        jButton5.setName("jButton5"); // NOI18N

        jButton6.setText("Cadastrar");
        jButton6.setName("jButton6"); // NOI18N

        jLabel7.setFont(new java.awt.Font("Dialog", 1, 9));
        jLabel7.setText("* Campo Obrigatorio");
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setFont(new java.awt.Font("Dialog", 1, 9));
        jLabel8.setText("* Campo Obrigatorio");
        jLabel8.setName("jLabel8"); // NOI18N

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTable1.setName("jTable1"); // NOI18N
        jScrollPane1.setViewportView(jTable1);

        jTabbedPane1.addTab("Curso", jScrollPane1);

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTable2.setName("jTable2"); // NOI18N
        jScrollPane2.setViewportView(jTable2);

        jTabbedPane1.addTab("Disciplina", jScrollPane2);

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        jTable3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTable3.setName("jTable3"); // NOI18N
        jScrollPane3.setViewportView(jTable3);

        jTabbedPane1.addTab("Professor", jScrollPane3);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 406, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel1))
                                .addGap(42, 42, 42)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 69, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                            .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE)
                                            .addGap(45, 45, 45))
                                        .addComponent(jLabel8))))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(97, 97, 97)
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 3, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(218, 218, 218))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButton6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton5)
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(5, 5, 5)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 39, Short.MAX_VALUE)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton6)
                    .addComponent(jButton5))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField2ActionPerformed

    private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
    }//GEN-LAST:event_jTextField3ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTable2;
    private javax.swing.JTable jTable3;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    // End of variables declaration//GEN-END:variables

    private Observavel docCurso = new Observavel();  
    private Observavel docNvagas = new Observavel();
      private Observavel docPeriodo= new Observavel();
      public List<Object> camposCurso = ClientCommand.getCampos("CursoService");//new ArrayList<Object>();
      private List<Object> valoresCurso = new ArrayList<Object>();
      public List<Object> camposDisciplina = ClientCommand.getCampos("CursoService");//new ArrayList<Object>();
      private List<Object> valoresDisciplina= new ArrayList<Object>();
      public List<Object> camposProfessor = ClientCommand.getCampos("CursoService");//new ArrayList<Object>();
      private List<Object> valoresProfessor = new ArrayList<Object>();
      private List<Object> tamanho = new ArrayList<Object>();
      List<Curso> extraCurso;
      List<Disciplina> extraDisciplina = new LinkedList<Disciplina>();
      List<Classe> extraClasse;
      List<Professor> extraProfessor;
      TabelaModelo tabModelCurso;
      TabelaModelo tabModelDisciplina;
      TabelaModelo tabModelProfessor;
      
    public void execute() {
         initComponents();
         if (cc==null)
                cc = new ConcretDecorator(this);
         tamanho.add("50");
         tabModelCurso = new TabelaModelo(camposCurso, tamanho, jTable1);
         tabModelDisciplina = new TabelaModelo(camposDisciplina, tamanho, jTable2);
         tabModelProfessor = new TabelaModelo(camposProfessor, tamanho, jTable3);
          initObserver();
          ListSelectionModel listModel1 = jTable1.getSelectionModel();
          listModel1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
          listModel1.addListSelectionListener(list1);
          setActions();
          ListSelectionModel listModel2 = jTable2.getSelectionModel();
          listModel2.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
          listModel2.addListSelectionListener(list2);
          
          ListSelectionModel listModel3 = jTable3.getSelectionModel();
          listModel3.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
          listModel3.addListSelectionListener(list3);
          setObjects();
//          campoObrigatorio();
          atualizaCurso();
          atualizaProfessor("*", "");
          cc.setVisible(true);
    }
     public void initObserver(){
        Observer val = new ValidaEspecial();
   
          docNvagas.setDocument(jTextField2.getDocument());
          docPeriodo.setDocument(jTextField3.getDocument());

          docNvagas.addObserver(val);
          docPeriodo.addObserver(val);

          jTextField2.getDocument().addDocumentListener(listener);
          jTextField3.getDocument().addDocumentListener(listener);
     }
     
      public void setTNvagas(Observavel observavel){
        observavel.setDocument(jTextField2.getDocument());
        observavel.setChanged();
        observavel.notifyObservers();
        jTextField2.setDocument(observavel.getDocument());

    }
            public void setTPeriodo(Observavel observavel){
        observavel.setDocument(jTextField3.getDocument());
        observavel.setChanged();
        observavel.notifyObservers();
        jTextField3.setDocument(observavel.getDocument());

    }

      public void getEventDocument(Document doc){
        if(doc.equals(docNvagas.getDocument()))
                setTNvagas(docNvagas);
        else if(doc.equals(docPeriodo.getDocument()))
                setTPeriodo(docPeriodo);
      }
 DocumentListener listener = new DocumentListener() {

            public void insertUpdate(DocumentEvent e) {
               getEventDocument(e.getDocument());
            }

            public void removeUpdate(DocumentEvent e) {
                getEventDocument(e.getDocument());
            }

            public void changedUpdate(DocumentEvent e) {
                 getEventDocument(e.getDocument());
            }
        };

        public void setCuso(final Curso curso){
        	this.curso = curso;       	
        }
        public void setProfessor(Professor professor){
        	this.professor = professor;
        }
        public void setDisciplina(Disciplina disciplina){
        	this.disciplina = disciplina;
        }
        public frmAtualizaTurma returnMe(){
        	return this;
        }
        public Curso getSelectedCurso(Long codigo){
    		return (Curso) ClientCommand.carregaObjeto("CursoService", "codigo ="+codigo, "");

    	}
        public Classe selectedClasse(Disciplina d){
    		return (Classe) ClientCommand.carregaObjeto("ClasseService", "codigo ="+d.getId(), "");

        }
        public Disciplina getSelectedDisciplina(Long codigo){
    		return (Disciplina) ClientCommand.carregaObjeto("DisciplinaService", "codigo ="+codigo, "");

    	}
        public Professor getSelectedProfessor(Long codigo){
    		return (Professor) ClientCommand.carregaObjeto("ProfessorService", "codigo ="+codigo, "");

    	}
        
        ListSelectionListener list1 = new ListSelectionListener() {
    		
    		@Override
    		public void valueChanged(ListSelectionEvent e) {
    			try{
    				if(jTable1.getSelectedRow()>=0){
    			curso = getSelectedCurso(Long.parseLong(jTable1.getValueAt(jTable1.getSelectedRow(), 0).toString()));
    	          atualizaDisciplina();
    				}
    			}catch(ArrayIndexOutOfBoundsException ea){
    				curso = null;
    			}
    		}
    	};	
        ListSelectionListener list2 = new ListSelectionListener() {
    		
    		@Override
    		public void valueChanged(ListSelectionEvent e) {
    			try{
    				if(jTable2.getSelectedRow()>=0){
    			disciplina = getSelectedDisciplina(Long.parseLong(jTable2.getValueAt(jTable2.getSelectedRow(), 0).toString()));
    			classe = selectedClasse(disciplina);
    				}
    			}catch(ArrayIndexOutOfBoundsException ea){
    				disciplina = null;
    			}
    		}
    	};
        ListSelectionListener list3 = new ListSelectionListener() {
    		
    		@Override
    		public void valueChanged(ListSelectionEvent e) {
    			try{
    				if(jTable3.getSelectedRow()>=0){
    			professor = getSelectedProfessor(Long.parseLong(jTable3.getValueAt(jTable3.getSelectedRow(), 0).toString()));
    				}
    				}catch(ArrayIndexOutOfBoundsException ea){
    				professor = null;
    			}
    		}
    	};
    	 public void atualizaCurso(){
    	    	((DefaultTableModel) jTable1.getModel()).setNumRows(0);
    	    	jTable1.updateUI();
    	    	extraCurso = (List)ClientCommand.carregar("CursoService"," codigo = codigo", "");
    	    	for(int i = 0; i < extraCurso.size();i++ ){
    	    		if(extraCurso.get(i).getId()==curso.getId())
    	    			jTable1.setRowSelectionInterval(jTable1.getRowCount()-1, jTable1.getRowCount()-1);
    	    		
    	    			valoresCurso = new LinkedList<Object>();
    	    		valoresCurso.add(extraCurso.get(i).getId());
    	    		valoresCurso.add(extraCurso.get(i).getNome());
    	    		valoresCurso.add(extraCurso.get(i).getAnoRegulamentado());
    	    		valoresCurso.add("********");
    	    		tabModelCurso.setValores(valoresCurso);
    	    		valoresCurso.clear();
    	    	}
    	    	
    	    }
    	  public void atualizaDisciplina(){
	     	extraDisciplina.clear();
  	    	((DefaultTableModel) jTable2.getModel()).setNumRows(0);
  	    	jTable2.updateUI();
  	    	extraClasse = (List)ClientCommand.carregar("ClasseService"," curso="+curso.getId()+" and periodo ="+jTextField3.getText(),"");
  	    	for(int i = 0; i < extraClasse.size();i++ ){
  	    		extraClasse.get(i).setDisicplina((Disciplina) ClientCommand.carregaObjeto("DisciplinaService","codigo ="+extraClasse.get(i).getDisicplina().getId(), ""));
  	    		extraDisciplina.add(extraClasse.get(i).getDisicplina());
  	    		//System.out.println(extraClasse.get(i).getDisicplina().getId());
  	    	}
  	    	
  	    	for(int i = 0; i < extraDisciplina.size();i++ ){
  	    		if(extraDisciplina.get(i).getId().equals(disciplina.getId()))
  	    			jTable2.setRowSelectionInterval(jTable2.getRowCount()-1, jTable2.getRowCount()-1);
  	    		valoresDisciplina = new LinkedList<Object>();
  	    		valoresDisciplina.add(extraDisciplina.get(i).getId());
  	    		valoresDisciplina.add(extraDisciplina.get(i).getNome());
  	    		if(( extraDisciplina.get(i)).getRequisito().getId()==0)
  	    			valoresDisciplina.add("Nenhum");
  				else{
  					(extraDisciplina.get(i)).setRequisito((Disciplina) ClientCommand.carregaObjeto("DisciplinaService","codigo = "+extraDisciplina.get(i).getRequisito().getId(), ""));
					valoresDisciplina.add(extraDisciplina.get(i).getRequisito().getNome());
  				}
  	    		//valores.add(extra.get(i).getRequisito().getId());
  	    		valoresDisciplina.add(extraDisciplina.get(i).getCargaHoraria());
  	     		tabModelDisciplina.setValores(valoresDisciplina);
  	     		valoresDisciplina.clear();
  	    	}
  	    }
    	  public void atualizaProfessor(String campos, String tabelasAdcionais){
          	((DefaultTableModel) jTable3.getModel()).setNumRows(0);
          	jTable3.updateUI();
          	this.extraProfessor = (List)ClientCommand.carregar("ProfessorService","codigo = codigo", "");
      		DataFacade entrada = new DataFacade();   
          	for(int i = 0; i < extraProfessor.size();i++ ){
          		if(extraProfessor.equals(professor))
          			jTable3.setRowSelectionInterval(i, i);
          		valoresProfessor = new LinkedList<Object>();
          		valoresProfessor.add(extraProfessor.get(i).getId());
          		valoresProfessor.add(extraProfessor.get(i).getNome());
          		valoresProfessor.add(extraProfessor.get(i).getCpf());
          		valoresProfessor.add(extraProfessor.get(i).getEndereco());
          		valoresProfessor.add(extraProfessor.get(i).getTelefone());
          		valoresProfessor.add(extraProfessor.get(i).getSexo());
          		valoresProfessor.add(extraProfessor.get(i).getRg());
          		valoresProfessor.add(extraProfessor.get(i).getCtps());
          		valoresProfessor.add(extraProfessor.get(i).getGraducao());
          		valoresProfessor.add(extraProfessor.get(i).getEspecializacao());
          		valoresProfessor.add(extraProfessor.get(i).getMestrado());
          		valoresProfessor.add(extraProfessor.get(i).getDoutorado());     		
          		valoresProfessor.add(entrada.getString(( extraProfessor.get(i)).getAnoEntrada()));
          		valoresProfessor.add(entrada.getString(( extraProfessor.get(i)).getAnosaida()));
          		valoresProfessor.add(extraProfessor.get(i).getLogin());
          		//valores.add(extra.get(i).getSenha());
          		valoresProfessor.add("********");
          		tabModelProfessor.setValores(valoresProfessor);
          		valoresProfessor.clear();       		
          	}
          }
    	  
    	  public void setObjects(){
    		  jTextField2.setText(String.valueOf(turma.getTamanho()));
			  jTextField3.setText(String.valueOf(turma.getPeriodo()));
			classe =(Classe) ClientCommand.carregaObjeto("ClasseService","codigo ="+turma.getClasse().getId(), "");
			curso = (Curso) ClientCommand.carregaObjeto("CursoService","codigo="+classe.getCurso().getId(), "");  
			disciplina = (Disciplina) ClientCommand.carregaObjeto("DisciplinaService","codigo ="+classe.getDisicplina().getId(), "");

			//atualizaDisciplina("*", "");
			professor = (Professor) ClientCommand.carregaObjeto("ProfessorService","codigo ="+turma.getProfessor().getId(), "");
    	  }
    	  public void setActions(){
    		  ActionListener listener = new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent arg0) {
					if(arg0.getSource().equals(jButton6))
					operacao();
					else
						cc.dispose();
				}
			};
			jButton6.addActionListener(listener);
			jButton5.addActionListener(listener);
    	  }
    	    public void limpaFields(){
    	       jTextField2.setText("");
    	       jTextField3.setText("");
    	    }

    	    
    		@Override
    		public void menuExemplo(JMenuItem item) {
    			// TODO Auto-generated method stub
    			
    		}

    		@Override
    		public void menuFechar(JMenuItem item) {
    			cc.dispose();		
    		}

    		@Override
    		public void menuLimpa(JMenuItem item) {
    			limpaFields();		
    		}

    		@Override
    		public void menuManual(JMenuItem item) {
    			// TODO Auto-generated method stub		
    		}

    		@Override
    		public void menuMementor(JMenuItem item) {
    			// TODO Auto-generated method stub		
    		}

    		@Override
    		public void menuOperacao(JMenuItem item) {
    			item.setText("Atualizar turma");
    			operacao();
    		}

    		@Override
    		public void menuSobre(JMenuItem item) {
    			// TODO Auto-generated method stub
    			
    		}
    	  
    	  public void operacao(){
    		  turma = new Turma();
				//classe = (Classe) classeDao.getObject(" disciplina ="+disciplina.getId()+" and curso = "+curso.getId(), "*", "");
				turma.setProfessor(professor);
				turma.setTamanho(Integer.parseInt(jTextField2.getText()));
				turma.setPeriodo(Integer.parseInt(jTextField3.getText()));
				turma.setClasse(classe);
				if(ClientCommand.alterar("TurmaService",turma)==true);	
					JOptionPane.showMessageDialog(null, "Turma Atualizada com Sucesso");
    	  }
}
